//
//  LXCommissionDetailCell.m
//  绿稀全球购
//
//  Created by 王敏 on 16/6/10.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "LXCommissionDetailCell.h"

@interface LXCommissionDetailCell()

@property(nonatomic,strong)UILabel * dateLabel;

@property(nonatomic,strong)UILabel * amountLabel;

@property(nonatomic,strong)UILabel * descLabel;

@end

@implementation LXCommissionDetailCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        
        self.cellHeight = 80;
        
        UILabel * dateLabel = [self creatLabel];
        [self.contentView addSubview:dateLabel];
        self.dateLabel = dateLabel;
        
        UILabel * amountLabel = [self creatLabel];
        [self.contentView addSubview:amountLabel];
        self.amountLabel = amountLabel;
        
        UILabel * descLabel = [self creatLabel];
        [self.contentView addSubview:descLabel];
        self.descLabel = descLabel;
        
        
        UIImageView * userIcon = [[UIImageView alloc] init];
        [self.contentView addSubview:userIcon];
        self.userIcon =  userIcon;
    }
    return self;
}


-(void)layoutSubviews{
    [super layoutSubviews];
    self.dateLabel.size = [self.dateLabel.text sizeInAre:MaxSize font:self.dateLabel.font];
    self.dateLabel.x = 10;
    self.dateLabel.centerY = self.cellHeight/2.0;
    
    self.userIcon.width = self.cellHeight/2.0;
    self.userIcon.height = self.userIcon.width;
    self.userIcon.x  = self.dateLabel.right + 5;
    self.userIcon.centerY = self.dateLabel.centerY;
    [self.userIcon addRadius:self.userIcon.height/2.0];
    
    self.amountLabel.size = [self.amountLabel.text sizeInAre:MaxSize font:self.amountLabel.font];
    self.amountLabel.x = self.userIcon.right+5;
    self.amountLabel.botton = self.cellHeight/2.0-5;
    
    self.descLabel.size = [self.descLabel.text sizeInAre:MaxSize font:self.descLabel.font];
    self.descLabel.x = self.amountLabel.x;
    self.descLabel.top = self.cellHeight/2.0+5;
    
}


-(UILabel*)creatLabel{
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.font = [UIFont systemFontOfSize:16];
    return label;
}


-(void)setDate:(NSString *)date{
    _date = date;
    self.dateLabel.text = date;
    
    [self setNeedsLayout];
}

-(void)setAmount:(CGFloat)amount{
    _amount = amount;
    self.amountLabel.text = [NSString stringWithFormat:@"%.2f",amount];
    [self setNeedsLayout];
}

-(void)setDesc:(NSString *)desc{
    _desc = desc;
    self.descLabel.text = desc;
    [self setNeedsLayout];
}

@end
